<template>
	<div class="products">
		<view class="item" v-for="item in list" :key="item.id" @click="openDetail(item)">
			<image :src="item.image" mode="aspectFit"></image>
			<text class="brand">{{item.brand}}</text>
			<view class="name">{{item.name}}</view>
			<view class="price">
				<text class="num">¥{{item.reduce_rmb}}</text>
				<view class="tag" v-if="item.flagAttr">{{item.flagAttr}}</view>
			</view>
			<text class="line-price">¥{{item.price}}</text>
		</view>
	</div>
</template>

<script>
	export default {
		data() {
			return {

			}
		},
		props: {
			list: {
				type: Array,
				default: () => []
			}
		},
		filters: {
			priceType(status) {
				let str = ''
				switch (status) {
					case 0:
						str = 'VIP价';
						break;
					case 1:
						str = '一口价';
						break;
					case 2:
						str = '活动价';
						break;
				}
				return str;
			}
		},
		methods: {
			openDetail(item) {
				uni.navigateTo({
					url: "/pages/goodsDetails/goodsDetails?id=" + item.id,
				});
			}
		}
	}
</script>

<style scoped lang="scss">
	.products {
		width: 100%;
		display: grid;
		grid-template-columns: repeat(2, 345rpx);
		justify-content: space-between;
		grid-row-gap: 20rpx;
		padding: 0 20rpx;
		width: 100%;

		.item {
			width: 100%;
			background-color: #fff;
			display: flex;
			flex-direction: column;
			box-sizing: border-box;
			padding: 20rpx;
			border-radius: 5rpx;

			.name,
			.brand {
				font-size: 24rpx;
			}

			.name {
				width: 100%;
				height: 68rpx;
				@extend .text-hidden-2
			}

			.price {
				display: flex;
				align-items: center;

				.num {
					font-size: 36rpx;
					font-weight: bold;
				}

				.tag {
					clip-path: polygon(0 50%, 15% 0, 100% 0, 100% 100%, 90% 100%, 15% 100%);
					margin-left: 5rpx;
					font-size: 20rpx;
					background: #CB712B;
					padding: 5rpx 10rpx;
					padding-left: 20rpx;
					transform: scale(.8);
					color: #fff;
					white-space: nowrap;
				}
			}

			.line-price {
				text-decoration: line-through;
				font-size: 28rpx;
				color: #999999;
			}

			image {
				width: 300rpx;
				height: 300rpx;
				margin-bottom: 39rpx;
			}
		}
	}
</style>
